# coding: UTF-8
###借款成功，下款的消息
from pyspark import SparkContext,SparkConf
from pyspark.sql import HiveContext
import sys, datetime, time,json
import urllib
reload(sys)
sys.setdefaultencoding('utf-8')
conf = SparkConf().set("spark.sql.parquet.compression.codec", "snappy")
sc = SparkContext("yarn-client", "online_finance", conf=conf)
sqlContext = HiveContext(sc)


def parse_data(pt):
    df=sqlContext.sql("""
        CREATE TABLE dw.test_20180626 as
        select
            *
        FROM
            dw.sms_log
        WHERE
            smslabel in ("互金观察","借吧微贷","借钱花","分期X","医购贷","品值APP","品值GO","品值生活","小微学贷","小易钱包","小薇学贷","希财网","惠人贷","易融数据","极速学贷","点信宝","点信网","猫小贷","缺钱么","誉用金服","贝尔在线","贴息猫","金票通","金蛛金服","闪电学贷","鼎丰汇贷通","91分期付","上纽资产","中鸿小贷","乐乐贷","予贷平台","创维财务","在线车融","大东北金融平台","天山金融","守财鹿","小鱼财富","易融通","易行通","易龙宝","普众房融通","渝信网","炫分期","百合贷","福金贷","笨熊科技","笨熊贷","飞乎分期","钱包君","简单借款","贷你嗨","秒白条","任信用","普惠快捷","分期GO","交单宝","北京学好贷公司","可信贷","和信信息","安投网","易美健","普天贷","火球网","百贷纵横","钱到到","钱加贝","随心贷","钱包贷","微赊","招财贷","美分分期","还呗app","蓝领小额","借条管家","借花花","华瑞借贷","D市惠联","财兜网","简易小贷","镰刀科技","龙游科技","融易付","西游科技","易赚通","百事易","吉米支付","快捷支付","容易付","闪讯付","团贷网","惠壹购","大众财务","借点钱","现金超人","校园宝","10金融","2345金融","517钱包","51金融圈","58名校贷","666财经","99贷","e互助","PPmoney","PPmoney理财","PP好花","PP理财","PP万惠分期","艾米金服","爱木财富","爱木投","安阳海鑫小贷","俺来也","按揭宝","奥利汇银","百发客","百付数据","百珺科技","百善世联","佰仟金融","般诺资产","北汽金融","贝格数据","财富咨询","财通资产","车能贷","晨星互动","催收宝","达飞金融","达利金融","大圣在线","大数金融","大圆银泰","贷通天下","德诚汇智","德厚融通","德粤财富","德众金融","第一创业","东方金钰","短线天天盈","多盈理财","房易贷","分利宝","分期客","分期派","蜂投网","福宝网","钢票网","给你花","管钱理财","光大分利宝","国美基金","国信香港","海马金服","海西金服","好车贷","合星普惠","合赢融通","合众e贷","和创科技","和赢科技","荷叶金融","恒安e贷","恒大金服","红岭创投","花生票号","华茂通大宗","徽农宝","徽盐金融","汇民通","汇通易贷","火箭理财","吉米钱包","吉小代","即刷即付","即有分期","加薪猫理财","家家基金","嘉联支付","嘉实财富","捷信公司","金饭碗","金海","金融猪","金象财富","金银岛","京小贷","鲸钱包","玖富超能","玖隆在线","聚财猫","聚金金融","君融贷","君融理财","卡牛信用卡管家","酷宝盒","快合作","蓝海财富","懒财网","乐保吧","乐金所","乐投创富","理财范","联金互联","联农贷金融平台","隆泰贷","麦嘟嘟","麦芽分期","民贷天下","名校贷","拇指闪贷","南宁大宗","你我贷","宁波大宗","牛板金","牛来了金服","农金财富","诺诺镑客","拍拍贷","票立贴","平安陆金所","平安银行","萍乡人保财险","浦发信用卡中心","普汇信融","企投网","起帮金融","起点贷","起亚金融","契域金融","仟金所","前海八实万","前海德晟","前海领投","钱富宝","钱海支付","钱记到家","钱胖胖","钱王万家","钱香金融","青鸟华光","人人融","融米钱包","融致金融","融祖金融","瑞福德金融","瑞金恒邦","三汇金融","闪电借款","闪电金融","闪电拍卖","闪银科技","深圳融邦","手机贷","谁牛金融","驷驭天下","随手贷","随手借点","随手网","穗金所","太保通","泰爱理财","淘钱宝","特权Go","天府银行","天合天益","天津金城银行","天天基金","天天乐贷","天天易","天雄投资","通惠保理","同鑫信息","铜钱贷","投哪网","万达金融","万达网络金融","万贯金融","万惠及贷","万讯盈科","唯金互联","维度招投标","稳快通","香蕉贷","小安理财","小安信贷","小财迷","小麦融贷","小米金融","小微时贷","小赢房贷","小赢普惠","小赢众信贷","新华久久贷","新浪分期","新锐盈","信而富","信和贷","星球金服","雅淘微贷","炎武金融","扬州农商行","一九付","一起创富","壹东方","壹公里","宜人贷","亿齐赢金融在线","易贷之家","易好贷","易通贷","易信金融","翼龙贷","银洲金服","悠财行","油菜花分期","友分期","友咖金服","有道金融","有用分期","源泰创投","远望金融","赟星金融","云之富","耘禾金服","长汇财富","长江创投","长江联合","涨呗网","掌趣科技","招财锁","招商基金","招商引资宝","挣钱宝V","中安信业","中房创投","中融汇金","中融汇金融","中新金服","中信联","中银消费金融","众安小赢","众客金融","众投邦平台","舟山大宗","助贷网","卓金金服","紫马财行","惠众借款","91钱","周转管家","和创金融","金太阳","钱知到","随心时贷","喔喔贷","大侠有米用","太空马","好快信","安在借条","尊贷网","小牛贷","律信智投","惠富天下","指尖金融","捷信","斑客小贷","沃腾金服周周贷","溢诚金融","秒易贷","简单贷微服务","蜀信","e资产","中金贷","云时贷","优房贷","先花一亿元","公明贷","医界贷","君鼎金服","图腾贷","圈圈贷","好又贷","平安普惠","我来贷","拍来贷","晋商贷","智投贷","玖信贷","睿信贷","融金所","超额宝","钱悦贷","钱贷网","雪山贷","魔法现金","黄金时贷","现金侠","永辉金融","靓号贷","唯你金服","债融易","利信易贷","麦粒贷","好贷网","闪贷网","胡桃钱包","还贷宝","聚宝网","融贷通赢","兴农宝","米米贷","开始钱包","慧火钱包","温州靓号贷","乐融金融","招联金融","海河金融","迅分期","还借钱","泽龙贷","金信网","金融一号店","品而金融","百联金融","米么金服","萨摩耶金服","车飞贷","益秒到","向钱贷","现金巴士","蚂蚁信贷","海金社","小赢理财","弘高融资","车贷中心","阳光互动","闪钱包","货车帮","小赢优贷","小微金融","言威金服","疯狂十八购","奥鹏教育","客音服务","学票官方","蘑菇街","哪吒钱包","青年贷","金驰投资","小赢卡贷","乐宝贝","新富贷","金泉网","信分宝","蓝领贷","元海服务","快贷App","一刻千金","国美金融","米米袋","湖北农信","多多金服","仟 易 贷","一信贷","誉府仕家","货拉拉","雅安商行","车e贷","益投资","极速花","共信赢","华澳融信","领航信息","恒信永利","普惠时代","钱有路","魔方公寓","校园通","仟易贷","资产360","和物按揭","嘉嘉购金融","好易借","建行山西分行","额度宝","东利莱金融","成都总商会小贷","车宝分","省呗","山西信合","顺时针","银商电子","恒舜普惠","现金卡贷","消费分期","帮你还","即分期","以诚为本信达天下","易房保","海恒投资","即出行","湖北消费金融","玖富叮当","玖富万卡","百度","借钱快","益芯金融","四平公积金","叮当钱包","快钱","金瑞龙","多好贷","优亿金融","长久贷","锐盈财富","索星金服","大业金融","大众迷你仓","吉兴捷","百贷宝","玖富","山水普惠","花无缺","城市红卡","润信小贷","齐海金融","合缘万卡","短融信息","浩森时贷","同心钱包","佐信资本","小猪快借","圆圆来了","百思贷","钱多多","快速借","乐醒","鑫天下","周末钱包","美分宝","第1车贷","人人贷金服","凤凰车贷","中资联","乔融","四川万基金融","菠萝袋","力驰机械","车丰汇","成都拓道金服","凡普信贷","京东金融","美眉分期","柠檬金服","华泰金融","鑫茂荣信","闪白条","财务之家","广能小贷","i品值","中贝金融","中国金融租赁","宜昌百财","成都华保","百望金赋","微品金融","畅快车贷","四川金穗","喜花花","百度金融","华睿钱包","领先贷","浩瀚金融","诚信通","现金卡","微钱贷","点融网","互惠理财网","现金秒贷","现金卡(白卡)","四川百旺金赋","亲亲小贷","富春贷","现金卡(金卡)","员工贷","天下信用","易众逸贷","打条吧","金管家","甲天下金融","小微钱包","百恒信贷","龙贷官方","四川仁信","汇银","慧通互联","小猪班纳","合众普惠","山西农信","正聚源","万商和通卡","诚旭钱包","人人信用","多-好-贷","陛博钱包","普洛斯金融","立即贷","原子贷","桔子分期","湖南住房公积金","云信通","信融财富","安心付","上汽通用金融","好贷宝","易代买","千金贷","快客贷","给你口袋","现金速递","黑卡","融360","普汇大通","农信宝","51人品","钱包优学","金联所","红天桃","孚金所","拿下钱包","钱速贷","拿下分期","七星分期","借得快","好易贷","触宝白条","新浪微贷","桔子钱包","富爵金服","兴仁金服","个人金融平台","卡行天下","卡牛","闪现贷款","工行汽车按揭","工行车贷","好钱包","财滚滚","益秒借","利信快捷金融","立下贷","神灯小贷","建元资本","微当钱包","幸福钱包","融通佰联","中融金","融通金融","还呗","广西众汇","有用","有钱用","马上消费金融","长安信托","广州共赢","九秒贷","先花花","51人品贷","台商地税","爱又米","恒分期","河北众投","流水贷","钱包闪贷","小秒钱包","第一房贷","普惠金融","亚亿金融")
    """)
    hdfs_path = """pt=%s""" % pt

    df.repartition(10).write.mode("overwrite").orc("/user/hive/warehouse/dw.db/online_finance/%s" % hdfs_path)
if __name__ == "__main__":
    print time.time()
    df = parse_data()
